<template>
	<view class="wrap">
		<view class="wrap__store">
			<view class="store__header">
				<view class="header__item">{{$t('ipo.name')}}</view>
				<view class="header__item">{{$t('ipo.price')}} </br>
				{{$t('ipo.nums')}}</view>
				<view class="header__item">{{$t('ipo.date')}}</view>
				<view class="header__item">{{$t('ipo.status')}}</view>
			</view>
			<view class="store__item" v-for="(item, index) in recordsList" :key="index">
				<view class="item__name">
					<view class="name__text">{{item.product.name}}</view>
					<view class="name__info">
						<text class="info__tag" v-if="item.product">{{item.product.zimudaima ? item.product.zimudaima.split(":")[0] : ""}}</text>
						<text class="info__code">{{item.product.shuzidaima}}</text>
					</view>
				</view>
				<view class="item__usable">
					<view class="usable__num">{{item.price}}</view>
					<text class="usable__num">{{item.shengoushuliang}}</text>
				</view>
				<view class="item__date">{{item.createtime }}</view>
				<!-- <view :class="['item__status', 'item__status--'+ item.status]">{{item.status | formatStatus}}</view> -->
				<view :class="['item__status', 'item__status--'+ item.status]"> {{$t('account.shen_'+item.status)}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {formatDate} from '@/common/js/utils.js'
	export default{
		data(){
			return {
				recordsList:[], //申购记录
			}
		},
		filters:{
			formatTime(timer){
				return  formatDate(timer * 1000)
			},
			formatStatus(status){
				/* let arr = ["申购中", "已中签", "未中签"] */
				 let arr = ["account.shen", "account.zhong", "account.wei"]
				return arr[status] || "-"
			}
		},
		onLoad() {
			// 获取申购记录
			this.getApplyRecords()
		},
		methods:{
			// 获取申购记录
			async getApplyRecords(){
				let res = await this.$api.getApplyBuyRecords()
				if(res && res.code === 1 && res.data){
					this.recordsList = res.data
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.wrap{
		min-height: 100vh;
		padding: 0 30rpx;
		box-sizing: border-box;
		.wrap__store{
			.store__title{
				font-size: 36rpx;
				font-weight: 800;
				color: #FFFFFF;
				@include flexRowAlign(center);
			}
			.store__header{
				margin-top: 20rpx;
				@include flexRowAlign(space-between);
				height: 64rpx;
				.header__item{
					@include flexRowAlign(center);
					font-size: 28rpx;
					color: #999999;
					width: 160rpx;
					.item__icon{
						width: 24rpx;
						height: 28rpx;
						margin-left: 4rpx;
					}
					&:nth-child(3){
						width: 180rpx;
					}
					&:first-child{
						justify-content: flex-start;
					}
					&:last-child{
						width: 150rpx;
					}
				}
			}
			.store__item{
				@include flexRowAlign(space-between);
				height: 120rpx;
				// border-top: 1rpx solid #EEEEEE;
				.item__name{
					@include flexCenter(column);
					align-items: flex-start;
					width: 180rpx;
					.name__text{
						font-size: 28rpx;
						color: #FFFFFF;
						width: 180rpx;
						@include textOver();
					}
					.name__info{
						@include flexRowAlign()
						margin-top: 10rpx;
						.info__tag{
							color: #161827;
							font-size: 20rpx;
							padding: 0 6rpx;
							height: 28rpx;
							background: #DE2804;
							border-radius: 6rpx;
							@include flexCenter();
						}
						.info__code{
							font-size: 20rpx;
							font-weight: 500;
							color:#fff;
							margin-left: 10rpx;
						}
					}
				}
				.item__usable{
					width: 160rpx;
					@include flexCenter(column);
					font-size: 26rpx;
					color: #fff;
					.usable__num{
						&:last-child{
							margin-top: 10rpx;
						}
					}
				}
				.item__date{
					@include flexCenter(column);
					text-align: center;
					font-size: 24rpx;
					color: #fff;
					width: 180rpx;
				}
				.item__status{
					@include flexCenter(column);
					width: 150rpx;
					font-size: 26rpx;
					font-weight: 800;
					color: #0369F6;
				}
				.item__status--1{
						color: #2DC065;
				}
				.item__status--2{
						color: #161827;
				}
			}
		}
	}
</style>